<?php

namespace App\Http\Request\Api\v1\Article;

use App\Utils\AppResult;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Http\Exceptions\HttpResponseException;

class InfoRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'id' => 'required|integer',
        ];
    }

    /**
     * 接管校验错误信息
     * @param \Illuminate\Contracts\Validation\Validator $validation
     */
    public function failedValidation($validation)
    {
        throw new HttpResponseException(AppResult::response203($validation->errors()->first()));
    }
}
